/**
 * Created by lizhe on 2018/5/14.
 */
var datas = [];
var first = [];
var second = [];
var third = [];

var menuId = 0;
var type = "";
var next = "";
$(document).ready(function(){
    menuId = getQueryString("menuId");
    type = getQueryString("type");
    next = getQueryString("next");
    queryList2(menuId);
    queryInfo(menuId);
});

function queryInfo(menuId){
    $.ajax({
        url : urladdr + "/website/teacherList",
        method : "GET",
        data : {
            menuId:menuId
        },
        success : function(data){
            if(data.code == 0){
                $("#content").empty();
                $.each(data.data,function(i,date){
                    document.getElementById("content").innerHTML = document.getElementById("content").innerHTML +
                        '<div class="teacherBar">'+
                        '<span class="teacharBarSpan">'+date.labelName+'</span>'+
                        '</div>';
                    $.each(data.data[i].webArticleEntities,function(j,dateJ){
                        var ext = JSON.parse(dateJ.ext);
                        var position = ext.position;
                        var icon =  imgUrl + dateJ.imageUrl;
                        document.getElementById("content").innerHTML = document.getElementById("content").innerHTML +
                            '<div class="teacherDivOut2" style="background: rgba(255,255,255,0);" onmousemove="mouseMove(this)" onmouseout="mouseOut(this)">'+
                            '<div class="teacherDiv" onclick=toInfo("'+dateJ.id+'")>'+
                            '<div class="teacherImgDiv">'+
                            '<img src="'+icon+'" class="teacherImg">'+
                            '<div class="teacherPost">'+ position +'</div>'+
                            '</div>'+
                            '<div class="teacherInfo">'+
                            '<div class="teacherName">'+ dateJ.title +'</div>'+
                            '</div>'+
                            '</div>'+
                            '</div>'
                    });
                    document.getElementById("content").innerHTML = document.getElementById("content").innerHTML +
                        '<div class="clearfix"></div>'
                });
            }else if(data.code == 401){
                location.href = "index.html"
            }else{
                modalinfo(data.msg);
            }
        }
    });
}

function toInfo(id){
    location.href = "teacherText.html?menuId="+menuId + "&id="+id + "&next="+next;
}

function mouseMove(obj){
    obj.style.background = "rgba(255,255,255,1)";
}

function mouseOut(obj){
    obj.style.background = "rgba(255,255,255,0)";
}